<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title>Title</title>

</head>
<body>


<p class="pnumber">段落1</p>
<p id="p2">段落2</p>
<p class="pnumber">段落3</p>
<p name="p4">段落4</p>
<p name="p4" class="pnumber">段落5</p>

<script>
    alert(document.getElementById("p2").innerHTML)

    var ps= document.getElementsByTagName("p");
            //document.getElementsByClassName("pnumber");
            /*
            //通过名字 name=p4
            =document.getElementsByName("p4");
            */
    for(var i=0;i<ps.length;i++){
        alert(ps[i].innerHTML)
    }
</script>
</body>
</html>